package com.ktjy.service.impl;



import com.ktjy.entity.Auction;
import com.ktjy.entity.AuctionVo;
import com.ktjy.mapper.AuctionMapper;
import com.ktjy.mapper.impl.AuctionMapperImpl;
import com.ktjy.service.AuctionService;
import com.ktjy.util.Page;

import java.util.HashMap;
import java.util.List;

public class AuctionServiceImpl implements AuctionService {
    private AuctionMapper auctionMapper=new AuctionMapperImpl();
    @Override
    public int insert(Auction auction) {
        return auctionMapper.insert(auction);
    }

    @Override
    public int update(Auction auction) {
        return auctionMapper.update(auction);
    }

    @Override
    public int countAuction(HashMap<String, Object> hashMap) {
        return countAuction(hashMap);
    }

    @Override
    public Page<Auction> getAuctionByPage(HashMap<String, Object> hashMap) {
        //1、统计数据总条数
        Integer totalCount=auctionMapper.countAuction(hashMap);
        //2、创建Page对象
        Page<Auction> page=new Page<>(totalCount,hashMap.get("pageNo"),hashMap.get("pageSize"));
        //3、分页查询数据
        hashMap.put("startRow",page.getStartRow());
        hashMap.put("pageSize",page.getPageSize());
        List<Auction> list=auctionMapper.getAuctionByPage(hashMap);
        //4、封装数据到page
        page.setList(list);
        return page;
    }

    @Override
    public List<AuctionVo> getEndAcution(Integer userId) {
        return auctionMapper.getEndAcution(userId);
    }

    @Override
    public List<Auction> getAuctioning() {
        return auctionMapper.getAuctioning();
    }
}
